<?php include_stylesheets_for_form($form) ?>
<?php include_javascripts_for_form($form) ?>
<?php use_javascript('colorpicker.js') ?>
<?php use_stylesheet('colorpicker') ?>

<script type="text/javascript" charset="utf-8">
//<![CDATA[
function toggle(checkboxID, toggleID) {
  var checkbox = document.getElementById(checkboxID);
  var toggle = document.getElementById(toggleID);
  updateToggle = checkbox.checked ? toggle.disabled=false : toggle.disabled=true;
}
//]]>
</script>

<?php if($sf_user->hasFlash('error')):?>
    <?php include_partial('global/msg', array('class'=>'error', 'msg'=>$sf_user->getFlash('error'))); ?>
<?php endif;?>
<?php if($sf_user->hasFlash('success')):?>
    <?php include_partial('global/msg', array('class'=>'success', 'msg'=>$sf_user->getFlash('success'))); ?>
<?php endif;?>

<div class="form">
<form action="<?php echo url_for($route) ?>" enctype="multipart/form-data" method="POST">

	<div><?php echo $form->renderGlobalErrors() ?></div>

	<table>
	<tr>
		<td class="label">
	    	<label class="required"><?php echo $form['name']->renderLabel() ?></label>
	    </td>
	    <td>
	        <?php echo $form['name'] ?>
	        <?php echo $form['name']->renderError() ?>
		</td>
	</tr>

	<tr>
		<td class="label">
	    	<label class="required"><?php echo $form['description']->renderLabel() ?></label>
	    </td>
	    <td>
	        <?php echo $form['description'] ?>
	        <?php echo $form['description']->renderError() ?>
		</td>
	</tr>

	<tr>
		<td class="label">
	    	<label class="required"><?php echo $form['logo']->renderLabel() ?></label>
	    </td>
	    <td>
	        <?php echo $form['logo'] ?>
	        <?php echo $form['logo']->renderError() ?>
		</td>
	</tr>

	<tr>
		<td class="label">
	    	<label class="required"><?php echo $form['payment_enabled']->renderLabel() ?></label>
	    </td>
	    <td>
	        <?php echo $form['payment_enabled']->renderRow(array('onclick' => "toggle('site_payment_enabled', 'site_dineromail_store_id')"), " ") ?>
	        <?php echo $form['payment_enabled']->renderError() ?>
		</td>
	</tr>

	<tr>
		<td class="label">
	    	<label class="required"><?php echo $form['dineromail_store_id']->renderLabel() ?></label>
	    </td>
	    <td>
	        <?php echo $form['dineromail_store_id'] ?>
	        <?php echo $form['dineromail_store_id']->renderError() ?>
		</td>
	</tr>

	<tr>
		<td class="label">
	    	<label class="required"><?php echo $form['background_image']->renderLabel() ?></label>
	    </td>
	    <td>
	        <?php echo $form['background_image'] ?>
	        <?php echo $form['background_image']->renderError() ?>
		</td>
	</tr>

	<tr>
		<td class="label">
	    	<label class="required"><?php echo $form['color_1']->renderLabel() ?></label>
	    </td>
	    <td>
	        <?php echo $form['color_1'] ?>
	        <?php echo $form['color_1']->renderError() ?>
		</td>
	</tr>

	<tr>
		<td class="label">
	    	<label class="required"><?php echo $form['color_2']->renderLabel() ?></label>
	    </td>
	    <td>
	        <?php echo $form['color_2'] ?>
	        <?php echo $form['color_2']->renderError() ?>
		</td>
	</tr>

	<tr>
		<td class="label">
	    	<label class="required"><?php echo $form['color_3']->renderLabel() ?></label>
	    </td>
	    <td>
	        <?php echo $form['color_3'] ?>
	        <?php echo $form['color_3']->renderError() ?>
		</td>
	</tr>

	<tr>
		<td class="label">
	    	<label class="required"><?php echo $form['location']->renderLabel() ?></label>
	    </td>
	    <td>
	        <?php echo $form['location'] ?>
	        <?php echo $form['location']->renderError() ?>
		</td>
	</tr>

	<tr>
		<td class="label">
	    	<label class="required"><?php echo $form['font']->renderLabel() ?></label>
	    </td>
	    <td>
	        <?php echo $form['font'] ?>
	        <?php echo $form['font']->renderError() ?>
		</td>
	</tr>

	<tr>
		<td class="label">
	    	<label class="required"><?php echo $form['category_id']->renderLabel() ?></label>
	    </td>
	    <td>
	        <?php echo $form['category_id'] ?>
	        <?php echo $form['category_id']->renderError() ?>
		</td>
	</tr>
	</table>
	<?php echo $form->renderHiddenFields() ?>
	<br><br>
	<input type="submit" class="button" value="Guardar" />&nbsp;&nbsp;
	<input type="button" value="Cancelar" onclick="history.back()">
</form>
</div>


<script type="text/javascript" charset="utf-8">
//<![CDATA[
$('site_dineromail_store_id').disabled = !($('site_payment_enabled').checked);

$('#site_color_1, #site_color_2, #site_color_3').ColorPicker({
            onSubmit: function(hsb, hex, rgb, el) {
                $(el).val('#' + hex);
                $(el).ColorPickerHide();
            },
            onBeforeShow: function () {
                $(this).ColorPickerSetColor('#' + this.value);
            }
        })
        .bind('keyup', function(){
            $(this).ColorPickerSetColor('#' + this.value);
        });
//]]>
</script>